export function formatTimeDifference(timestamp) {
  const now = new Date().getTime();
  const difference = now - timestamp;

  if (difference < 60000) {
    return '1 分钟内';
  } else if (difference < 3600000) {
    return Math.floor(difference / 60000) + ' 分钟';
  } else if (difference < 86400000) {
    return Math.floor(difference / 3600000) + ' 小时';
  } else if (difference < 2592000000) {
    return Math.floor(difference / 86400000) + ' 天';
  } else if (difference < 7776000000) {
    return Math.floor(difference / 259200000) + ' 月';
  } else {
    return null;
  }
}

export function gotoHome(){
	uni.showModal({
		title:"提示",
		content:"参数有误，返回首页",
		showCancel:false,
		success(res) {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}

// 示例用法
// const timestamp = 1692787200000;  // 示例时间戳
// const result = formatTimeDifference(timestamp);
// console.log(result); 